<script setup>
import {ref,reactive} from "vue";
import axios from "axios"

let message = ref('');
let code = ref(0);

let msgObj=reactive({
    code:0,
    content:''
})

// let getMessage=()=>{
//     let result = axios({
//         url:"http://forum.atguigu.cn/api/rand.qinghua?format=json",
//         method:"get"
//     })
//     // console.log(result);
//     result.then(
//         (res)=>{
//             message.value=res.data.content;
//             console.log(res);
            
//         }
//     )
// }

let getMessage = async()=>{
    //解析-->解构
    let {data} = await axios({
        url:"http://forum.atguigu.cn/api/rand.qinghua?format=json",
        method:"get"
    })
    //相当于拷贝
    Object.assign(msgObj,data);
}

</script>

<template>
  <div>

    <button @click="getMessage()">土味情话</button>


    <h1>{{ msgObj }}</h1>
  </div>
</template>

<style scoped>

</style>
